<template>
  <div>
    <!--title-->
    <header class="title-person">
      <h3 class="title-h3">我的</h3>
    </header>
    <!--headImg-->
    <div class="head-img-div">
      <img src="../../../static/512.png" class="head-img"/>
      <br />
      <div v-if="!isLogin" class="loginBtn" @click="doLogin">登录</div>
      <div v-else class="nickName">{{nickName}}</div>
    </div>
    <!--message-->
    <!--<div class="message-div">
      <ul>
        <li><i class="iconfont">&#xe6ed;</i><span>我的积分</span></li>
        <li><i class="iconfont">&#xe605;</i><span>我的评论</span></li>
        <li><i class="iconfont">&#xe70a;</i><span>消息中心</span><span class="fr">></span></li>
      </ul>
    </div>-->
    <!--set up-->
    <div class="setUp-div">
      <ul>
        <li @click="getKefu"><i class="iconfont">&#xe603;</i><span>客服与帮助</span><span class="fr">></span></li>
        <li @click="goSend"><i class="iconfont">&#xe6e2;</i><span>身份认证</span><span class="fr">></span></li>
        <li @click="toInvitation"><img src="../../../static/yaoqing.png" style="width: 1rem;margin-right: .5rem;"/><span>邀请码</span><span class="fr">></span></li>
        <li @click="toSetup"><i class="iconfont">&#xe728;</i><span>设置</span><span class="fr">></span></li>
      </ul>
    </div>
  </div>
</template>

<script>
//import {findNickName} from '../../api/goods.js'
export default {
  data () {
    return {
      isLogin: false,
      nickName: '',
      userNum: ''
    }
  },
  methods: {
    doLogin () {
      this.$router.push({path: '/login'})
    },
    toSetup () {
      this.$router.push('/setup')
    },
    toInvitation () {
      this.$router.push('/invitation')
    },
    getKefu () {
      this.$router.push('/kefu')
    },
    goSend () {
      this.$router.push('/send')
    }
  },
  created: function () {
    this.isLogin = JSON.parse(localStorage.isLogin)
    if (this.isLogin) {
      this.userNum = this.$store.state.userNum
      this.nickName = localStorage.nickName
    }
  },
  mounted () {
    let that = this
    var first = null
    mui.init({
      keyEventBind: {
        backbutton: true  //关闭back按键监听
      }
    })
    mui.back = function () {
      if (
        that.$route.name === 'zulin' ||
        that.$route.name === 'order' ||
        that.$route.name === 'person'
      ) {
        if (!first) {
          first = new Date().getTime()
          mui.toast('再按一次退出应用')
          setTimeout(function () {
            first = null
          }, 1000)
          error
        } else {
          if (new Date().getTime() - first < 1000) {
            plus.runtime.quit()
            error
          }
        }
      }
      error
    }
  }
}
</script>

<style scoped>
  .title-person{
    text-align: center;
    height: 2rem;
    line-height: 2rem;
    background: #fff;
  }
  .title-h3{
    font-size: .8rem;
    color: #000;
  }
  .head-img-div{
    margin: .35rem 3%;
    /*box-sizing: border-box;*/
    height: 7.5rem;
    text-align: center;
    border-radius: .3rem;
    box-shadow: 0 0 0.3rem #b5b5b6;
    background: url(../../../static/bg.jpg) no-repeat;
    background-size: 100% 100%;
    position: relative;
  }
  .head-img{
    width: 3rem;
    height: 3rem;
    vertical-align: middle;
    position: absolute;
    left: 50%;
    margin-left: -1.5rem;
    top: 1.2rem;
  }
  .loginBtn{
    position: absolute;
    left: 50%;
    margin-left: -1.5rem;
    bottom: 1.2rem;
    width: 3rem;
    height: 1.5rem;
    border-radius: .75rem;
    border: 1px solid #000;
    line-height: 1.5rem;
    color: #000;
    font-size: .7rem;
  }
  .nickName{
    position: absolute;
    left: 50%;
    margin-left: -1.5rem;
    bottom: 1.2rem;
    width: 3rem;
    height: 1.5rem;
    line-height: 1.5rem;
    color: #000;
    font-size: .7rem;
  }
  .message-div{
    margin: .7rem 3% 0;
    border-radius: .3rem;
    box-shadow: 0 0 0.3rem #b5b5b6;
    background: #fff;
    font-size: .7rem;
    line-height: 1.5rem;
    padding: .5rem;
  }
  .setUp-div{
    margin: .7rem 3% 0;
    border-radius: .3rem;
    box-shadow: 0 0 0.3rem #b5b5b6;
    background: #fff;
    font-size: .7rem;
    line-height: 1.5rem;
    padding: .5rem;
  }
  li i, li span{
    vertical-align: middle;
    display: inline-block;
    line-height: 1.5rem;
  }
  li i{
    margin-right: .5rem;
  }
  li span{
    font-size: .6rem;
  }
</style>
